package com.modules.controller.sys;


import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.common.controller.MyController;
import com.common.log.LogData;
import com.common.vo.Result;
import com.modules.entity.sys.OrganizationEntity;
import com.modules.service.sys.OrganizationService;


/**
 * 组织控制层
 * @author yyq
 *
 */
@Controller
@RequestMapping("/sys/organization")
public class OrganizationController extends MyController<OrganizationEntity>{
	
	@Autowired
	private OrganizationService service;
	
	
	/**
	 * 查询单个
	 * @return
	 */
	@RequestMapping("/selectOne")
	@ResponseBody
	public Result<?> selectOne(OrganizationEntity org){
		return service.selectOne(org);
	}
	/**
	 * 查询
	 * @return
	 */
	@RequestMapping("/select")
	@ResponseBody
	public Result<?> select(){
		return service.select(getUser().getLastOid());
	}
	/**
	 * 查询所有项目
	 * @return
	 */
	@RequestMapping("/selectAllProject")
	@ResponseBody
	public Result<?> selectAllProject(){
		return service.selectAllProject(getUser().getLastOid());
	}

	/**
	 * 保存
	 * @return
	 */
	@RequestMapping("/save")
	@ResponseBody
	public Result<?> save(OrganizationEntity org, HttpServletRequest request){
		String menu0 = request.getParameter("menu0");
		String menu1 = request.getParameter("menu1");
		String menu2 = request.getParameter("menu2");
		return service.save(org,menu0,menu1,menu2);
	}
	
	/**
	 * 删除
	 * @return
	 */
	@LogData(module = "组织管理", remarks = "删除单个")
	@RequestMapping("/delete")
	@ResponseBody
	public Result<?> delete(OrganizationEntity org){
		return service.delete(org.getOid());
	}
	
	/**
	 * 生成账号密钥
	 * @return
	 */
	@LogData(module = "组织管理", remarks = "生成账号秘钥")
	@RequestMapping("/createCodeAndPass")
	@ResponseBody
	public Result<?> createCodeAndPass(String value){
		return service.createCodeAndPass(value);
	}
	
	
	
	
	
}